<?php 
namespace Admin\Model;
use Think\Model\ViewModel;
class MemberViewModel extends ViewModel{
	//视图模型关联表
	public $viewFields = array(
		'member'=>array('id','username','email','score','logintime','loginip','status'),
		'auth_group_access'=>array('uid,group_id','_on'=>'auth_group_access.uid=member.id'),
		'auth_group'=>array('title','_on'=>'auth_group_access.group_id=auth_group.id'),
	);
	//输出所有用户
	public function getUsers($number,$order){
		$count = $this->count();
		$Page  = new \Library\Page($count,$number);// $number为分页数
		$Page->setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% <li>%HEADER%</li>');
		$data['page'] = $Page->show();// 分页显示输出
		$data['users'] =
			   $this->order($order)
					->limit($Page->firstRow.','.$Page->listRows)
					->select();
		return $data;
	}
	//输出所有用户
	public function getGroupUsers($number,$where="",$order){
		$count = $this->count();
		$Page  = new \Library\Page($count,$number);// $number为分页数
		$Page->setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% <li>%HEADER%</li>');
		$data['page'] = $Page->show();// 分页显示输出
		$data['users'] =
			   $this->order($order)
			   		->where("auth_group.id=".$where)
					->limit($Page->firstRow.','.$Page->listRows)
					->select();
		return $data;
	}	
}

 ?>